/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jjsoft.disco.gco.mdl;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Johnny
 */
@Entity
@Table(name = "factura_compra", catalog = "discodb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FacturaCompra.findAll", query = "SELECT f FROM FacturaCompra f"),
    @NamedQuery(name = "FacturaCompra.findByIdFactura", query = "SELECT f FROM FacturaCompra f WHERE f.idFactura = :idFactura"),
    @NamedQuery(name = "FacturaCompra.findByNumFactura", query = "SELECT f FROM FacturaCompra f WHERE f.numFactura = :numFactura"),
    @NamedQuery(name = "FacturaCompra.findByDescueto", query = "SELECT f FROM FacturaCompra f WHERE f.descueto = :descueto"),
    @NamedQuery(name = "FacturaCompra.findByEstado", query = "SELECT f FROM FacturaCompra f WHERE f.estado = :estado"),
    @NamedQuery(name = "FacturaCompra.findByFechaEmision", query = "SELECT f FROM FacturaCompra f WHERE f.fechaEmision = :fechaEmision"),
    @NamedQuery(name = "FacturaCompra.findByIva12", query = "SELECT f FROM FacturaCompra f WHERE f.iva12 = :iva12"),
    @NamedQuery(name = "FacturaCompra.findBySubtotal", query = "SELECT f FROM FacturaCompra f WHERE f.subtotal = :subtotal"),
    @NamedQuery(name = "FacturaCompra.findByTotal", query = "SELECT f FROM FacturaCompra f WHERE f.total = :total"),
    @NamedQuery(name = "FacturaCompra.findByGuiaRemision", query = "SELECT f FROM FacturaCompra f WHERE f.guiaRemision = :guiaRemision")})
public class FacturaCompra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idFactura;
    @Basic(optional = false)
    @Column(nullable = false)
    private int numFactura;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(precision = 22)
    private Double descueto;
    private Integer estado;
    @Column(name = "fecha_emision")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaEmision;
    @Column(precision = 22)
    private Double iva12;
    @Column(precision = 22)
    private Double subtotal;
    @Column(precision = 22)
    private Double total;
    @Column(name = "guia_remision", length = 45)
    private String guiaRemision;
   
    @JoinColumn(name = "idProveedor", referencedColumnName = "idProveedor", nullable = false)
    @ManyToOne(optional = false)
    private Proveedor idProveedor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idFactura")
    private List<DetalleCompra> detalleCompraList;

    public FacturaCompra() {
    }

    public FacturaCompra(Integer idFactura) {
        this.idFactura = idFactura;
    }

    public FacturaCompra(Integer idFactura, int numFactura) {
        this.idFactura = idFactura;
        this.numFactura = numFactura;
    }

    public Integer getIdFactura() {
        return idFactura;
    }

    public void setIdFactura(Integer idFactura) {
        this.idFactura = idFactura;
    }

    public int getNumFactura() {
        return numFactura;
    }

    public void setNumFactura(int numFactura) {
        this.numFactura = numFactura;
    }

    public Double getDescueto() {
        return descueto;
    }

    public void setDescueto(Double descueto) {
        this.descueto = descueto;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public Date getFechaEmision() {
        return fechaEmision;
    }

    public void setFechaEmision(Date fechaEmision) {
        this.fechaEmision = fechaEmision;
    }

    public Double getIva12() {
        return iva12;
    }

    public void setIva12(Double iva12) {
        this.iva12 = iva12;
    }

    public Double getSubtotal() {
        return subtotal;
    }

    public void setSubtotal(Double subtotal) {
        this.subtotal = subtotal;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    public String getGuiaRemision() {
        return guiaRemision;
    }

    public void setGuiaRemision(String guiaRemision) {
        this.guiaRemision = guiaRemision;
    }

   

    public Proveedor getIdProveedor() {
        return idProveedor;
    }

    public void setIdProveedor(Proveedor idProveedor) {
        this.idProveedor = idProveedor;
    }

    @XmlTransient
    @JsonIgnore
    public List<DetalleCompra> getDetalleCompraList() {
        return detalleCompraList;
    }

    public void setDetalleCompraList(List<DetalleCompra> detalleCompraList) {
        this.detalleCompraList = detalleCompraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFactura != null ? idFactura.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FacturaCompra)) {
            return false;
        }
        FacturaCompra other = (FacturaCompra) object;
        if ((this.idFactura == null && other.idFactura != null) || (this.idFactura != null && !this.idFactura.equals(other.idFactura))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jjsoft.celularessuc.gco.mdl.FacturaCompra[ idFactura=" + idFactura + " ]";
    }
    
}
